<!DOCTYPE html> 
<html> 
	<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1"> 
	<title>jQuery Mobile Docs - Responsive Layout Helpers</title> 
	<link rel="stylesheet"  href="../../jquery.mobile-1.0.min.css" /> 
	<link rel="stylesheet" href="../_assets/css/jqm-docs.css"/>
	<script src="../../jquery.js"></script>
	<script src="../../experiments/themeswitcher/jquery.mobile.themeswitcher.js"></script>
	<script src="../_assets/js/jqm-docs.js"></script>
	<script src="../../jquery.mobile-1.0.min.js"></script>
</head> 
<body> 

<div data-role="page" class="type-interior">

	<div data-role="header" data-theme="f">
		<h1>Responsive Layout Helpers</h1>
		<a href="../../" data-icon="home" data-iconpos="notext" data-direction="reverse" class="ui-btn-right jqm-home">Home</a>
	</div><!-- /header -->

	<div data-role="content" data-theme="c">
			
			<div class="content-primary">
			<h2>Media Query Helper Classes</h2>
<p class="ui-bar-e ui-body"><strong>Note: This feature was deprecated in beta, and removed in 1.0rc1. We recommend using CSS3 Media Queries instead.</strong> To support older versions of Internet Explorer, check out <a href="https://github.com/scottjehl/Respond">respond.js</a>, a fast &amp; lightweight polyfill for min/max-width CSS3 Media Queries.</p>
			<p class="ui-bar-e ui-body">If you still need this feature, you can find the code here: <a href="https://raw.github.com/jquery/jquery-mobile/38d7ad8848f00b0921bf4ae723f3ad199eb851c1/js/jquery.mobile.media.classes.js">jquery.mobile.media.classes.js</a></p>
			
			<p>jQuery Mobile adds classes to the <code>HTML</code> element that mimic browser orientation and common min/max-width CSS media queries. These classes are updated on load, resize and orientationchange, allowing you to key off these classes in your CSS, to create <a href="http://www.alistapart.com/articles/responsive-web-design/">responsive layouts</a> - even in browsers that don't support media queries! </p>
			
			<h3>Orientation Classes </h3>

			<p>The HTML element will always have a class of either <code>"portrait"</code> or <code>"landscape"</code>, depending on the orientation of the browser or device. You can utilize these in your CSS like this:</p>
			<pre>
			<code>
.portrait {
	/* portrait orientation changes go here! */
}
.landscape {
	/* landscape orientation changes go here! */
}			
			</code>
			</pre>
			
			<h3>Min/Max Width Breakpoint Classes</h3>
			<p>By default, we create min and max breakpoint classes at the following widths: <code>320</code>,<code>480</code>,<code>768</code>,<code>1024</code>. These translate to classes that look like this: <code>"min-width-320px"</code>, <code>"max-width-480px"</code>, and are meant to be used as a replacement of (or in addition to) the media query equivalents they mimic.</p>
<pre>
			<code>
.myelement { 
	float: none;
}			
.min-width-480px .myelement {
	float: left;
}		
			</code>
</pre>		
			
			<p>Many plugins in jQuery Mobile leverage these width breakpoints. For example, form elements float beside their labels when the browser is wider than 480 pixels. The CSS to support this behavior for form text inputs looks like this:</p>
			
<pre>
			<code>
label.ui-input-text { 
	display: block; 
}
.min-width-480px label.ui-input-text { 
	display: inline-block; 
}
			</code>
</pre>		

			<h3>Adding Width Breakpoints</h3>
		<p>To utilize width breakpoints of your own, jQuery Mobile exposes the <code>$.mobile.addResolutionBreakpoints </code> function, which accepts either a single number or array of numbers that will be added to the min/max breakpoints whenever they apply.</p>
<pre>
			<code>
//add a min/max class for 1200 pixel widths			
$.mobile.addResolutionBreakpoints(1200);

//add min/max classes for 1200, and 1440 pixel widths			
$.mobile.addResolutionBreakpoints([1200, 1440]);
			</code>
</pre>	

<h3>Running Media Queries</h3>
<p>jQuery Mobile provides a function that allows you to test whether a particular CSS Media Query applies. Simple call <code>$.mobile.media()</code> and pass a media type or query. If the browser supports that type or query, and it currently applies, the function will return true. If not, it'll return false.</p>

<pre>
			<code>
//test for screen media type
$.mobile.media("screen");

//test  a min-width media query
$.mobile.media("screen and (min-width: 480px)");

//test for iOS retina display
$.mobile.media("screen and (-webkit-min-device-pixel-ratio: 2)");

			</code>
</pre>
					
	</div><!--/content-secondary -->		
	
	<div class="content-secondary">
		
		<div data-role="collapsible" data-collapsed="true" data-theme="b" data-content-theme="d">
			
				<h3>More in this section</h3>
				
				<ul data-role="listview"  data-theme="c" data-dividertheme="d">
				
					<li data-role="list-divider">API</li>
					<li><a href="../../docs/api/globalconfig.html">Configuring defaults</a></li>
					<li><a href="../../docs/api/events.html">Events</a></li>
					<li><a href="../../docs/api/methods.html">Methods &amp; Utilities</a></li>
					<li data-theme="a"><a href="../../docs/api/mediahelpers.html">Responsive Layout</a></li> 
					<li><a href="../../docs/api/data-attributes.html">Data attribute reference</a></li>
					<li><a href="../../docs/api/themes.html">Theme framework</a></li>
				</ul>
		</div>
	</div>		

</div><!-- /content -->

<div data-role="footer" class="footer-docs" data-theme="c">
		<p>&copy; 2011 The jQuery Project</p>
</div>
	
</div><!-- /page -->

</body>
</html>